#include "wheelzoomfontsize.h"


WheelZoomFontSize::WheelZoomFontSize(QWidget *parent)
    :QTextEdit(parent)
{

}

void WheelZoomFontSize::wheelEvent(QWheelEvent *e)
{
    if(ctrlPressed == 1){
        if(e->angleDelta().y() > 0)
        {
            zoomIn();
        }
        else if(e->angleDelta().y() < 0)
        {
            zoomOut();
        }
        else
        {
            QTextEdit::wheelEvent(e);
        }
    }
}

void WheelZoomFontSize::keyPressEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_Control)
    {
        ctrlPressed = 1;
    }
    QTextEdit::keyPressEvent(e);  // 其他功能全都由父类的方法去完成
}

void WheelZoomFontSize::keyReleaseEvent(QKeyEvent *e)
{
    if(e->key() == Qt::Key_Control)
    {
        ctrlPressed = 0;
    }
    QTextEdit::keyReleaseEvent(e);
}
